﻿<Page x:Class="Wokhan.WindowsFirewallNotifier.Console.UI.Pages.Rules"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
      DataContext="{Binding RelativeSource={RelativeSource Self}}"
      mc:Ignorable="d" 
      d:DesignHeight="400" d:DesignWidth="800"
	Title="Firewall rules">
    <DockPanel>
        <Border DockPanel.Dock="Top">
            <Border.Style>
                <Style TargetType="Border" BasedOn="{StaticResource InfoPanel}">
                    <Setter Property="Visibility" Value="Collapsed" />
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding IsFirewallEnabled}" Value="False">
                            <Setter Property="Visibility" Value="Visible" />
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </Border.Style>
            <TextBlock Text="The Windows embedded firewall is currently disabled. The following rules will not apply until you enable it back, either using WFN notifications options or the standard Windows firewall ones." />
        </Border>
        <Border Style="{StaticResource ToolBarPanel}">
            <Grid>
                <WrapPanel>
                    <Button x:Name="btnRemoveRule" Click="btnRemoveRule_Click">
                        <Grid>
                            <Path Fill="OrangeRed" Data="{StaticResource Image_Delete}"/>
                            <TextBlock Margin="20,0,0,0" Text="Remove" />
                        </Grid>
                    </Button>
                    <Button x:Name="btnLocate" Click="btnLocate_Click">
                        <Grid>
                            <Path Fill="CornflowerBlue" Data="{StaticResource Image_Locate}"/>
                            <TextBlock Margin="20,0,0,0" Text="Locate" />
                        </Grid>
                    </Button>
                    <Button x:Name="btnStartAdvConsole" Click="btnStartAdvConsole_Click">
                        <Grid>
                            <Image Source="/WFN;component/Resources/Images/btnOpenConsole.Image.png" HorizontalAlignment="Left" Height="16"/>
                            <TextBlock Margin="20,0,0,0" Text="Adv. console" />
                        </Grid>
                    </Button>
                </WrapPanel>
                <WrapPanel HorizontalAlignment="Right">
                    <Path Fill="Orange" Data="{StaticResource Image_Filter}"/>
                    <Label Content="Filter:" />
                    <TextBox x:Name="txtFilter" Width="150" Text="{Binding Filter, UpdateSourceTrigger=PropertyChanged}" />
                    <Path Height="14" Fill="Green" Data="{StaticResource Image_Show}"/>
                    <Label Content="Show:" />
                    <ComboBox IsEditable="False" Width="100" SelectedValue="{Binding TypeFilter}" DisplayMemberPath="Value" SelectedValuePath="Key" ItemsSource="{Binding TypeFilters}" />
                    <Button x:Name="btnRefresh" Click="btnRefresh_Click">
                        <Path Fill="#FFA2A2FF" Data="{StaticResource Image_Refresh}"/>
                    </Button>
                    <ToggleButton x:Name="btnHelp">
                        <Path Fill="Chocolate" Data="{StaticResource Image_Help}"/>
                    </ToggleButton>
                </WrapPanel>
            </Grid>
        </Border>
        <Grid>
            <DataGrid AlternatingRowBackground="Gainsboro" BorderThickness="0" x:Name="gridRules" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ColumnWidth="*" GridLinesVisibility="None" SelectionMode="Single" IsReadOnly="True" ItemsSource="{Binding connectionsView}" AutoGenerateColumns="False" HeadersVisibility="Column">
                <DataGrid.CellStyle>
                    <Style TargetType="DataGridCell" BasedOn="{StaticResource {x:Type DataGridCell}}">
                        <Setter Property="VerticalAlignment" Value="Center" />
                    </Style>
                </DataGrid.CellStyle>
                <DataGrid.Columns>
                    <DataGridTextColumn Header="Name" Binding="{Binding Name, Mode=OneTime}" />
                    <DataGridTemplateColumn Header="Path" SortMemberPath="ApplicationName">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <Grid>
                                    <Image Source="{Binding Icon, Mode=OneTime}" Width="16" HorizontalAlignment="Left"/>
                                    <Label Content="{Binding ApplicationName, Mode=OneWay}" Margin="20,0,0,0" />
                                </Grid>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>
                    <DataGridTextColumn Header="Service" Binding="{Binding serviceName, Mode=OneTime}" />
                    <DataGridTextColumn Header="Direction" Binding="{Binding DirectionStr, Mode=OneTime}" />
                    <DataGridTextColumn Header="Profiles" Binding="{Binding ProfilesStr, Mode=OneTime}" />
                    <DataGridTextColumn Header="Action" Binding="{Binding ActionStr, Mode=OneTime}" />
                    <DataGridTextColumn Header="Local ports" Binding="{Binding LocalPorts, Mode=OneTime}" />
                    <DataGridTextColumn Header="Remote addresses" Binding="{Binding RemoteAddresses, Mode=OneTime}" />
                    <DataGridTextColumn Header="Remote port" Binding="{Binding RemotePorts, Mode=OneTime}" />
                    <DataGridCheckBoxColumn Header="Enabled" Binding="{Binding Enabled, Mode=OneTime}" />
                </DataGrid.Columns>
            </DataGrid>
            <Border Style="{StaticResource InfoBlock}">
                <TextBlock>This screen displays all Windows firewall rules. The ones prefixed by "Custom rules" have been created by Windows Firewall Notifier. You can not manually create rules, but you can remove useless ones if required.</TextBlock>
            </Border>
        </Grid>
    </DockPanel>
</Page>
